// 入驻申请
<template>
   <div class="search">
     <Row>
        <Card>
          <Row class="operation">
            <Form inline :label-width="100" ref="searchForm" :model="searchForm" label-position="right">
              <Button @click="getDataList()" icon="md-refresh">刷新</Button>
              <FormItem label="商家名称" prop="storeName">
                <Input type="text" v-model="searchForm.storeName" placeholder="请输入商家名称"/>
              </FormItem>
              <FormItem label="客户手机号" prop="phone">
                <Input v-model="searchForm.phone" placeholder="请输入客户手机号" />
              </FormItem>
              
              <FormItem label="支付开始时间" prop="payTimeBeginTime">
                <Date-picker type="datetime" placeholder="选择日期和时间" style="width: 200px" @on-change="changeTime($event,'begin')"></Date-picker>
              </FormItem>
              <FormItem label="支付结束时间" prop="payTimeEndTime	">
                <Date-picker type="datetime" placeholder="选择日期和时间" style="width: 200px" @on-change="changeTime($event,'end')"></Date-picker>
              </FormItem>
              <FormItem label="订单方式" prop="orderStatus">
                <Select v-model="searchForm.orderStatus" style="width:200%" clearable>
                  <Option value="PRE_PAY">待付款</Option>
                  <Option value="PRE_SEND">待处理</Option>
                  <Option value="DELIVER_SEND">已处理</Option>
                  <Option value="PRE_COMMENT">待评价</Option>
                  <Option value="SALE_AFTER">退款售后</Option>
                  <Option value="CANCEL_ORDER">取消订单</Option>
                  <Option value="IS_COMPLETE">完成订单</Option>
                  <Option value="RETURN_FINISH">退款完成</Option>
                </Select>
              </FormItem>
              <Button @click="handleSearch" type="primary" icon="ios-search" style="margin-left:100px;">搜索</Button>
            </Form>
          </Row>

          <Modal title="查看大图" v-model="visible" class-name="fl-image-modal">
            <img :src="imgUrl" style="width: 100%">
          </Modal>

          <Row>
            <Table :loading="loading" border :columns="columns" :data="data" ref="table" sortable="custom" @on-sort-change="changeSort"></Table>
          </Row>

          <Row type="flex" justify="end" class="page">
            <Page :current="searchForm.pageNumber" :total="total" :page-size="searchForm.pageSize" @on-change="changePage" @on-page-size-change="changePageSize" :page-size-opts="[10,20,50]" size="small" show-total show-elevator show-sizer></Page>
          </Row>
        </Card>
     </Row>
     <Modal :title="modalTitle" v-model="detailVisible" :mask-closable='false' :width="800">
      <div style="padding: 10px 0;font-size: 16px;"><label>商品名称：</label>{{goodsDetail.name}}</div>
      <div style="padding: 10px 0;font-size: 16px;"><label>商品图片：</label><img :src="goodsDetail.pic" style="width: 200px"/></div>
      <div style="padding: 10px 0;font-size: 16px;"><label>商品类型：</label>{{goodsDetail.shopCartType}}</div>
      <div style="padding: 10px 0;font-size: 16px;"><label>购买类型：</label>{{goodsDetail.buyType}}</div>
      <div style="padding: 10px 0;font-size: 16px;"><label>购买数量：</label>{{goodsDetail.buyCount}}</div>
      <div style="padding: 10px 0;font-size: 16px;"><label>尾款：</label>{{goodsDetail.goodBalancePayment}}</div>
      <div style="padding: 10px 0;font-size: 16px;"><label>定金：</label>{{goodsDetail.goodDeposit}}元</div>
      <div style="padding: 10px 0;font-size: 16px;"><label>价格：</label>{{goodsDetail.price}}元</div>
      <div style="padding: 10px 0;font-size: 16px;"><label>满减金额：</label>{{goodsDetail.subtractMoney}}元</div>
      <div style="padding: 10px 0;font-size: 16px;">
        <label>规格属性：</label>
        <div v-for="(item,index) in goodsDetail.attrSymbolPath" :key="index">
          <span>规格{{index+1}}：{{item.attrValue}}</span>
        </div>
      </div>
    </Modal>

   </div> 
</template>

<script>
export default {
  data(){
    return{ 
      detailVisible: false,
      visible:false,
      total:0,
      loading: true, // 表单加载状态
      data:[],//表单数据
      imgUrl: "",
      goodsDetail: {},
      searchForm:{
        storeId: "",
        storeName: "",
        payTimeBeginTime: "",
        payTimeEndTime: "",
        phone: "",
        orderStatus: "",
        pageSize:10,
        pageNumber:1
      },
      columns: [
      // 表头
      {
        type: "index",
        width: 60,
        align: "center"
      },
      {
        title: "订单编号",
        key: "orderNum",
        minWidth: 120,
        sortable: false,
      },
      {
        title: "订单类型",
        key: "typeEnum",
        minWidth: 120,
        sortable: false,
      },
      {
        title: "用户名",
        key: "nickName",
        minWidth: 120,
        sortable: false,
      },
      {
        title: "店家名称",
        key: "storeName",
        minWidth: 120,
        sortable: false,
      },
      {
        title: "购买人",
        key: "consignee",
        minWidth: 120,
        sortable: false,
      },
      {
        title: "联系方式",
        key: "phone",
        minWidth: 120,
        sortable: false,
      },
      {
        title: "运费（元）",
        key: "freightPrice",
        minWidth: 100,
        sortable: false,
      },
      {
        title: "订单总金额（元）",
        key: "totalPrice",
        minWidth: 130,
        sortable: false,
      },
      {
        title: "支付方式",
        key: "payTypeEnum",
        minWidth: 120,
        sortable: false,
      },
      {
        title: "尾款支付类型",
        key: "rentPayType",
        minWidth: 120,
        sortable: false,
      },
      // {
      //   title: "收货地址",
      //   key: "address",
      //   minWidth: 120,
      //   sortable: false,
      // },
      {
        title: "订单状态",
        key: "orderStatus",
        minWidth: 120,
        sortable: false,
      },
      {
        title: "创建时间",
        key: "createTime",
        minWidth: 120,
        sortable: false,
      }, 
      ]}
    },
    methods:{
      init(){
        this.getDataList()
      },
      handleView(url) {
        this.imgUrl = url;
        this.visible = true;
      },
      changeTime (event, val) {
        (val == "begin") ? (this.searchForm.payTimeBeginTime = event) : (this.searchForm.payTimeEndTime = event)
      },
      getDataList(){
        if (this.searchForm.orderStatus === undefined) {
          this.searchForm.orderStatus = "";
        }
        this.loading = true;
        this.postRequest("/order/getInsuranceList",this.searchForm).then(res =>{
          this.loading = false
          if(res.success){
            var arr = res.result.dataResult;
            for(let val of arr){
              for(let i in val){
                (val[i] === null) ? (val[i] = "-") : ""
              }
            }
            this.data = arr;
            this.total = res.result.totalPage;
          } else {
            this.data = [];
            this.total = 0;
          }
        })
      },
      //搜索查询
      handleSearch(){
        this.searchForm.pageNumber = 1;
        this.getDataList()
      },
      changeSort(e) {
        this.searchForm.sort = e.key;
        this.searchForm.order = e.order;
        if (e.order === "normal") {
          this.searchForm.order = "";
        }
        this.getDataList();
      },
      changePage(v) {
        this.searchForm.pageNumber = v;
        this.getDataList();
      },
      changePageSize(v) {
        this.searchForm.pageSize = v;
        this.getDataList();
      },
      clearSelectAll(){
        this.$refs.searchForm.resetFields()
        this.getDataList()
      },
    },
    mounted(){
        this.init()
    }
}
</script>

<style lang="less">
.search {
    .operation {
        margin-bottom: 2vh;
    }
    .select-count {
        font-size: 13px;
        font-weight: 600;  
        color: #40a9ff;
    }
    .select-clear {
        margin-left: 10px;
    }
    .page {
        margin-top: 2vh;
    }
    .drop-down {
        font-size: 13px;
        margin-left: 5px;
    }
}
</style>